package com.tjp.eight.ui.fragment.personsetting;

import com.tjp.eight.AllRetrofit;
import com.tjp.eight.ResultModel;
import com.tjp.eight.base.BasePresenterImpl;
import com.tjp.eight.constant.UrlConstant;
import com.tjp.eight.net.NetCallBack;
import com.tjp.eight.net.SubscribeCallBack;
import com.tjp.eight.utils.AppUtils;

import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/3/23.
 */
public class InputCodePresenter extends BasePresenterImpl<InputCodeView> {
    private InputCodeService service = AllRetrofit.getRetrofit(UrlConstant.BaseUrl).create(InputCodeService.class);

    public InputCodePresenter(InputCodeView view) {
        attachView(view);
    }

    public void submitCode(String pJson) {
        RequestBody body = AppUtils.getRequestBody(pJson);
        addSubscription(service.submit(body), new SubscribeCallBack<>(new NetCallBack<ResultModel>() {
            @Override
            public void onSuccess(ResultModel model) {
                view.uploadSuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {
                view.fail(msg);
            }

            @Override
            public void onCompleted() {

            }
        }));
    }
}
